<?
    final class Principio_View_Helper_ActionMenu extends Zend_View_Helper_Abstract
    {
        public function actionMenu()
        {

            $html = "<div id=\"right_menu\"><ul>";

            foreach($this->view->model_action_menu->getMenu()->getListElementIterator() as $list_element)
            {
                $model_menu_item = $list_element->getValue();

                $html .=  "<li class=\"";

                if ($list_element->isLast())
                    $html .= "last";

                if (($this->view->action == $model_menu_item->getAction()) || (($this->view->action == "view") && ($model_menu_item->getAction() == "edit")))
                    $html .= ($list_element->isLast() ? ", " : "")."active";

                $html .= "\"><a href=\"#\" ";

                if ($model_menu_item->getAction() == "delete")
                {
                    $html .= "onClick=\"if(confirm('Sure?')) {ajax".$this->view->model_action_menu->getJsAjaxFunction()."({id: ".$this->view->model_action_menu->getItemID().", action: '".$model_menu_item->getAction()."', use_inner: true";

                    foreach ($this->view->model_action_menu->getAdditionalArgs() as $id => $value)
                        $html .= ", ".$id.": ".$value;

                    $html .= "});} else event.stopPropagation();\"";
                }
                else
                    $html .= "onClick=\"ajax".$this->view->model_action_menu->getJsAjaxFunction()."({id: ".$this->view->model_action_menu->getItemID().", action: '".$model_menu_item->getAction()."', no_apply: true});\"";

                $html .= ">".$model_menu_item->getCaption()."</a></li>";
            };

            $html .= "</ul></div>";
            return $html;
        }
    };
?>